package com.wp.美团;

import java.util.Scanner;

/**
 * @author 王萍
 * @date 2018/3/22 0022
 */
public class 数字字符 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.next();
        int[] ints = new int[10];
        for (int i = 0; i < str.length(); i++) {
            ints[str.charAt(i) - '0']++;
        }
        for (int i = 1; i < ints.length; i++) {
            if (ints[i] == 0) {
                System.out.println(i);
                return;
            }
        }
        if (ints[0] == 0) {
            System.out.println(10);
        }
        int count = ints[1];
        for (int i = 2; i < ints.length; i++) {
            if (ints[i] < count) {
                for (int j = 1; j < count; j++) {
                    i = i * 10 + i;
                }
                System.out.println(i);
                return;
            }
        }

        if (ints[0] == count) {
            int i = 1;
            for (int j = 0; j < count; j++) {
                i = i * 10 + i;
            }
            System.out.println(i);
            return;
        }
        if (ints[0] < count) {
            int i = 10;
            for (int j = 1; j < count; j++) {
                i = i * 10;
            }
            System.out.println(i);
            return;
        }
    }
}